<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method='html' encoding='UTF-8' doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" indent='yes'/>

	<!-- xml filesources -->
	<xsl:variable name="src_head" select="document(root/filehead/@src)"/>
	<xsl:variable name="src_head_ie" select="document(root/filehead_ie/@src)"/>
	<xsl:variable name="src_header" select="document(root/fileheader/@src)"/>
	<xsl:variable name="src_navbar" select="document(root/filenavbar/@src)"/>
	<xsl:variable name="src_footer" select="document(root/filefooter/@src)"/>
	<xsl:variable name="src_data" select="document(root/input/filedata)"/>
	
	<!-- template to load a static content -->
	<xsl:template name="Loader">
		<xsl:param name="src"/>  
		<xsl:copy-of select="$src/root/*[name() != 'namespace']"/>
	</xsl:template>

	<!-- template to load extra data content -->
	<xsl:template name="ExtraDataLoader">
		<xsl:param name="src"/>
		<xsl:copy-of select="$src/*[name() != 'namespace']"/>
	</xsl:template>
	
	<!-- template to load IE Fix content -->
	<xsl:template name="IELoader">
		<xsl:param name="src"/>
		<xsl:comment>[if IE 6]><xsl:value-of select="$src"/>&lt;![endif]</xsl:comment>
	</xsl:template>
	
	<!-- template to dinamically create menu -->
	<xsl:template name="NavLoader">
		<xsl:param name="src"/>
		<xsl:variable name="page" select="page"/>
		<xsl:copy-of select="$src/root/linkable/*"/>
		<!-- navbar link list -->
		<!--<ul id="nav_list">
			<xsl:if test="page = 'browse'">
				<xsl:copy-of select="$src/root/not_linkable/ul/li[text()='Home']"/>
			</xsl:if>
			<xsl:if test="page != 'browse'">
				<xsl:copy-of select="$src/root/linkable/ul/li[a[@accesskey='o']]"/>					
			</xsl:if>
			<xsl:if test="page = 'feedscribe'">
				<xsl:copy-of select="$src/root/not_linkable/ul/li[text()='Sign Up']"/>
			</xsl:if>
			<xsl:if test="page != 'feedscribe'">
				<xsl:copy-of select="$src/root/linkable/ul/li[a[@accesskey='s']]"/>
			</xsl:if>
			<xsl:if test="page = 'unfeedscribe'">
					<xsl:copy-of select="$src/root/not_linkable/ul/li[text()='Help']"/>
			</xsl:if>
			<xsl:if test="page != 'unfeedscribe'">
				<xsl:copy-of select="$src/root/linkable/ul/li[a[@accesskey='h']]"/>
			</xsl:if>
			<xsl:if test="page = 'manage'">
				<xsl:copy-of select="$src/root/not_linkable/ul/li/a[text()='About']"/>
			</xsl:if>
			<xsl:if test="page != 'manage'">
				<xsl:copy-of select="$src/root/linkable/ul/li[a[@accesskey='a']]"/>
			</xsl:if>
		</ul>-->
	</xsl:template>

	<!-- template to load extra data content -->
	<xsl:template name="GroupsLoader">
		<xsl:param name="src"/>
		<xsl:param name="groupname"/>
		<xsl:for-each select="$src/userfeed/group[@groupname != $groupname]">
			<option><xsl:value-of select="@groupname"/></option>
		</xsl:for-each>
	</xsl:template>
	
	
	<!-- template to generate main content -->
	<xsl:template name="BrowseContent">
		<!-- load extra tabindex params 
		<xsl:call-template name="ExtraDataLoader">
			<xsl:with-param name="src" select="extradata/tabindex"/>
		</xsl:call-template> -->
		<!-- main tab page -->
		 <div id="feed_wrapper">
			<h1>Your Feeds</h1>
			<span class="help_ico"><a href="../help.html" id="feed_wrapper_help" rel="This column is the list of all the feeds you previously subscribed. Click on one of them to have, here on the right, the list of all its items" onclick="return false;"><img src="../images/icons/help.png" alt="help" /></a></span>
			<!-- FEED TOOLS SECTION -->
			<ul class="order_tools">
				<li><span id="feeds_filter_tool" class="filter" title="Filter">Filter</span></li>
			  <li><span class="order_tag" title="Order by Tag">order by tag</span></li>
			  <li><span class="order_alpha"  title="Alphabetical Order">alphabetical order</span></li>
			</ul>
			<div class="filter_box" id="feed_filter">
				<label for="feed_search">Filter feeds </label><br/>
			  <form>
				<input id="feed_search" type="text" value="Search..." onfocus='this.value = ""'/>
				<input id="feeds_filter_submit" type="submit" value="Go!" onclick="return false;" />
				</form>
			</div>
			<!-- END FEED TOOLS SECTION -->
			<ul id="feed_list">
				<xsl:for-each select="$src_data/userfeed/group">
					<li><a class="group_title" href="#"><xsl:value-of select="@groupname"/></a>
						<xsl:if test="feed">
							<ul class="feed_group">
								<xsl:for-each select="feed">
									<li><a>
										<xsl:variable name="xlink"><xsl:value-of select="link"/></xsl:variable>
										<xsl:attribute name="href"><xsl:value-of select="$xlink"/></xsl:attribute>
										<xsl:attribute name="onclick">loadFeedItems('<xsl:value-of select="$xlink"/>'); return false;</xsl:attribute>
										<xsl:value-of select="name"/>
									</a></li>
								</xsl:for-each>
							</ul>
						</xsl:if>
						<xsl:if test="not(feed)">
							<ul class="empty_group"><li><a>&lt;empty></a></li></ul>
						</xsl:if>
					</li>
				</xsl:for-each>
			</ul>
		</div>
		<!-- END FEEDS WRAPPER -->
  
		<!-- FEED ITEMS WRAPPER -->
		<div id="feed_items_wrapper">
			<h1>Feed Items</h1>
			<span class="help_ico"><a href="../help.html" id="feed_items_help" rel="In this column you have the list of all the items of the feed you selected on the left. Click one of them to see its content" onclick="return false;"><img src="../images/icons/help.png" alt="help" /></a></span>
			<!-- FEED ITEMS TOOLS -->
				<ul class="order_tools">
				<li><span id="items_filter_tool" class="filter" title="Filter">Filter</span></li>
				</ul>
			   <div class="filter_box" id="items_filter">
					<form>
					<label for="items_search">Filter items </label><br/>
				  <input id="items_search" type="text" value="Search..." onfocus='this.value = ""'/>
				  <input id="items_filter_submit" type="submit" value="Go!" onclick="return false"/>
				</form>
				</div>
			<!-- END FEED ITEMS TOOLS -->
			<!-- Qui va il contenuto dinamico creato con javascript -->
			  <p id="he">Select a feed first</p>
		</div>
		<!-- END FEED ITEMS WRAPPER -->
		  
		<!-- FEED ITEM CONTENT WRAPPER -->
		<div id="feed_content_wrapper">
			<h1>Feed Item Content</h1>
			 <span class="help_ico"><a href="../help.html" id="feed_content_help" rel="Here is the content of the item you previously selected. Maybe the content you see here is not the whole content of the article. To be sure, follow the link under the title to travel to the original post." onclick="return false;"><img src="../images/icons/help.png" alt="help" /></a></span>
			<!-- Contenuto della descrizoine dell'item generato con javascript -->
			<p id="he_cont">Select a feed item to view the description here</p>  
		</div>
		<!-- END FEED ITEM CONTENT WRAPPER -->
		
	</xsl:template>
	
	<!-- CREATE PAGE -->
	
	<!-- create page structure -->
	<xsl:template match="root">
		<html>
			<!-- head -->
			<head>
				<!-- load common code -->
				<xsl:call-template name="Loader">
					<xsl:with-param name="src" select="$src_head"/>
				</xsl:call-template>
				<!-- load extra head params -->
				<xsl:call-template name="ExtraDataLoader">
					<xsl:with-param name="src" select="extradata/head"/>
				</xsl:call-template>
				<!-- load ie fix -->
				<xsl:call-template name="IELoader">
					<xsl:with-param name="src" select="$src_head_ie/root/common"/>
				</xsl:call-template>
				<xsl:call-template name="IELoader">
					<xsl:with-param name="src" select="extradata/IEFix"/>
				</xsl:call-template>
				<!-- pagetitle -->
				<title><xsl:value-of select="pagetitle"/></title>
			</head>
			<body>
				<!-- body onload attribute -->
				<xsl:if test="extradata/body/onload/text() != ''">
					<xsl:attribute name="onLoad"><xsl:value-of select="extradata/body/onload"/></xsl:attribute>
				</xsl:if>
				<!-- header -->			
				<xsl:call-template name="Loader">
					<xsl:with-param name="src" select="$src_header"/>
				</xsl:call-template>
				<div id="content_wrapper">
					<!-- navbar -->
					<div id="main_app_navigation">
						<xsl:call-template name="NavLoader">
							<xsl:with-param name="src" select="$src_navbar"/>
						</xsl:call-template>
					</div>
					<!-- noscript -->
					<xsl:call-template name="ExtraDataLoader">
						<xsl:with-param name="src" select="extradata/noscript"/>
					</xsl:call-template>				
					<!-- access -->
					<xsl:call-template name="ExtraDataLoader">
						<xsl:with-param name="src" select="extradata/access"/>
					</xsl:call-template>
					<!-- content -->
					<xsl:call-template name="BrowseContent">
						<!--<xsl:with-param name="src" select="$src_footer"/>-->
					</xsl:call-template>
				</div>
				<!-- footer -->
				<xsl:call-template name="Loader">
					<xsl:with-param name="src" select="$src_footer"/>
				</xsl:call-template>				
			</body>
		</html>
	</xsl:template>
	
</xsl:stylesheet>	
